/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.gob.fonafe.dao.impl.stored;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import javax.sql.DataSource;
import oracle.jdbc.OracleTypes;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.object.StoredProcedure;
import pe.gob.fonafe.domain.EmpresaBean;
/**
 *
 * @author Irving
 */
public class ListarEmpresasSP extends StoredProcedure{
     private static final String PROC_PARAM ="USERADMIN.P_OBT_LIST_EMPRESAS";
              
    public ListarEmpresasSP(DataSource ds) {
        super(ds,PROC_PARAM);
        declareParameter(new SqlOutParameter("cCursor", OracleTypes.CURSOR,new ListarEmpresasRowMapper()));
        compile();
    }
    
    public Map execute() {
        Map inputs = new HashMap();
        return super.execute(inputs);
    }
    
    private static class ListarEmpresasRowMapper implements RowMapper<EmpresaBean>{
   
        public EmpresaBean mapRow(ResultSet rs, int rowNum) throws SQLException {
            EmpresaBean bean = new EmpresaBean();
            bean.setId_empresa(rs.getInt("id_empresa"));
            bean.setNombre_empresa(rs.getString("nombre_empresa"));
            return bean;
        }
    }
    
}
